package org.example.api;

import org.example.dao.ArticleDao;
import org.example.model.Article;
import org.example.util.WebUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/blog/detail")
public class BlogDetailServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取请求数据：文章id
        String id = req.getParameter("id");
        //通过文章id查询文章信息
        Article a = ArticleDao.queryBlogDetail(Integer.parseInt(id));
        WebUtil.serialize(resp, a);
    }
}
